package StrategyPattern;/** * Created by Administrator on 2018-10-17. * 鸭子基类 */public abstract class Duck {    FlyBehavior flyBehavior;    QuackBehavior quackBehavior;    //    public void swim(){//        System.out.println("I Can swim!");//    }////    public void display(){//        System.out.println("我的外表颜色！");//    }    public Duck() {    }    /**     * 鸭子外表 抽象     */    public abstract void display();    /**     * 鸭子飞行行为 委托给FlyBehavior 行为类     */    public void performFly() {        flyBehavior.fly();    }    public void performQuack() {        quackBehavior.quack();    }    public void swim() {        System.out.println("I Can swim!");    }    public void setFlyBehavior(FlyBehavior fb) {        flyBehavior = fb;    }    public void setQuackBehavior(QuackBehavior qb) {        quackBehavior = qb;    }}